<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    用户名：<input type="text"><br />
    密码:<input type="text"><br />
    验证码：<input type="text" id="yy"><span id="tt">哒哒</span><br />
    <button id="btn">登录</button><span id="bb"></span>
</body>

</html>
<script src="./js/tools.js"></script>
<script>
    window.onload = function () {
        var oSpan = document.getElementById("tt")
        console.log(oSpan.innerHTML);

        tt.onclick = function () {
            var a = randomNum(0, 10).toString()
            var b = randomNum(0, 10).toString()
            var c = randomNum(0, 10).toString()
            var d = randomNum(0, 10).toString()
            var yan =a+b+c+d
            oSpan.innerHTML = yan
        }
        btn.onclick=function(){
            console.log(123)
            if(tt.innerHTML==yy.value){
                bb.style.color="red"
                bb.innerHTML="亲,验证码正确,可以登录！"
            }else{
                bb.style.color="green"
                bb.innerHTML="请重新输入验证码！"
            }
        }
    }
</script>